home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / intrlib1.zip / INTR_LIB.H < prev    next >
C/C++ Source or Header  |  1992-02-17  |  18KB  |  457 lines

  1. /******************************************************************************
  2. * MSDOS Interaction library main header file.                      *
  3. *                                          *
  4. *                    Written by Gershon Elber,  Oct. 1990  *
  5. *******************************************************************************
  6. * History:                                      *
  7. *  3 Oct 90 - Version 1.0 by Gershon Elber.                      *
  8. ******************************************************************************/
  9.  
  10. #ifndef INTR_LIB_H
  11. #define INTR_LIB_H
  12.  
  13. #ifdef DJGCC
  14. #include <graphics.h>
  15. #endif /* DJGCC */
  16.  
  17. #ifndef TRUE
  18. #define TRUE 1
  19. #define FALSE 0
  20. #endif
  21.  
  22. #ifdef NO_VOID_PTR
  23. #define VoidPtr        char *
  24. #else
  25. #define VoidPtr        void *
  26. #endif /* NO_VOID_PTR */
  27.  
  28. #define IntrBType int                              /* Boolean type. */
  29. #define IntrRType float                     /* Floating point type. */
  30.  
  31. #define INTR_WNDW_PULL_DOWN   -10000 /* WindowID signals pull down position. */
  32. #define INTR_WNDW_PLACE_CENTER    0    /* WindowID signals screen position. */
  33. #define INTR_WNDW_PLACE_LEFT    -1
  34. #define INTR_WNDW_PLACE_RIGHT    -2
  35.  
  36. typedef enum {
  37.     INTR_EVNT_NONE = 0,
  38.     INTR_EVNT_SELECT,
  39.     INTR_EVNT_ABORT,
  40.     INTR_EVNT_MIDDLE_BUTTON,
  41.     INTR_EVNT_MOVE,
  42.     INTR_EVNT_KEY,
  43.     INTR_EVNT_REFRESH
  44. } IntrEventType;
  45.  
  46. typedef enum {                    /* Window type supported by library. */
  47.     INTR_WNDW_NONE = 0,
  48.     INTR_WNDW_GRAPH = 1,
  49.     INTR_WNDW_TEXT = 2,
  50.     INTR_WNDW_ROOT = 4
  51. } IntrWindowType;
  52.  
  53. typedef enum {                /* Scroll bar type supported by library. */
  54.     INTR_SCRLBAR_NONE = 0,
  55.     INTR_SCRLBAR_LEFT,
  56.     INTR_SCRLBAR_RIGHT,
  57.     INTR_SCRLBAR_TOP,
  58.     INTR_SCRLBAR_BOTTOM
  59. } IntrScrlBarType;
  60.  
  61. typedef enum {                      /* Color supported by library. */
  62.     INTR_COLOR_WHITE = 0,
  63.     INTR_COLOR_BLACK,
  64.     INTR_COLOR_RED,
  65.     INTR_COLOR_GREEN,
  66.     INTR_COLOR_BLUE,
  67.     INTR_COLOR_YELLOW,
  68.     INTR_COLOR_CYAN,
  69.     INTR_COLOR_MAGENTA,
  70.  
  71.     INTR_NUM_COLORS,
  72.  
  73.     INTR_COLOR_NONE
  74. } IntrColorType;
  75.  
  76. typedef enum {                /* Four intensity levels for each color. */
  77.     INTR_INTENSITY_VHIGH = 0,
  78.     INTR_INTENSITY_HIGH,
  79.     INTR_INTENSITY_LOW,
  80.     INTR_INTENSITY_VLOW
  81. } IntrIntensityType;
  82.  
  83. typedef enum {                 /* Type of input devices supported. */
  84.     INTR_INPT_DEVICE_MOUSE = 1,
  85.     INTR_INPT_DEVICE_JOYSTICK = 2,
  86.     INTR_INPT_DEVICE_KEYBOARD = 4
  87. } IntrInputDeviceType;
  88.  
  89. typedef enum {                        /* Type of cursor shape. */
  90.     INTR_CURSOR_CROSS,
  91.     INTR_CURSOR_CROSS_LAST,
  92.     INTR_CURSOR_SCROSS,
  93.     INTR_CURSOR_ARROW,
  94.     INTR_CURSOR_BOX,
  95.     INTR_CURSOR_BOX_LAST,
  96.     INTR_CURSOR_CUSTOM,
  97.     INTR_CURSOR_MASK,
  98.  
  99.     INTR_CURSOR_PUSH,
  100.     INTR_CURSOR_POP
  101. } IntrCursorType;
  102.  
  103. typedef enum {
  104.     INTR_SAVE_CONV,
  105.     INTR_SAVE_EMS,
  106.     INTR_SAVE_XMS,
  107.     INTR_SAVE_DISK
  108. } IntrSaveMemType;
  109.  
  110. typedef enum {
  111.     INTR_FILL_SOLID = 1
  112. } IntrFillType;
  113.  
  114. typedef void (* IntrVoidFunc)(void);
  115. typedef void (* IntrIntFunc)(int);
  116. typedef IntrEventType (* IntrInt2PtrFunc)(int *, int *);
  117.  
  118. typedef struct {
  119.     int Xmin, Ymin, Xmax, Ymax, _Dx, _Dy;
  120. } IntrBBoxStruct;
  121.  
  122. typedef struct {
  123.     IntrRType FXmin, FYmin, FXmax, FYmax, _FDx, _FDy;
  124. } IntrFBBoxStruct;
  125.  
  126. typedef struct IntrCursorShapeStruct {
  127.     IntrCursorType CursorType;
  128.     int Width, Height;           /* Width/Height information to use if needed. */
  129.     int LastX, LastY;        /* LastX/LastY information to use if needed. */
  130.     IntrBType LastHV;          /* If TRUE Draw Horiz/Vert line to last coord. */
  131.     void (* CursorRoutine)(int, int);
  132.     IntrBType _CursorVisible;
  133. } IntrCursorShapeStruct;
  134.  
  135. typedef struct {
  136.     char *TextData;
  137.     IntrBType ReadBottomLine;      /* If bottom line is used as reading line. */
  138.     IntrColorType TextColor, BottomLineColor;
  139.     int NumOfLines;                 /* Number of lines to be saved. */
  140.     int LineLen;                      /* Maximum length of line. */
  141.     int LinesInBuffer;                          /* Number of lines active. */
  142.     int FirstDisplayed;                        /* First line displayed. */
  143.     int NumOfDisplayedLines;          /* Depends on current window size. */
  144. } _IntrWndwTextStruct;
  145.  
  146. typedef struct _IntrWindowStruct {
  147.     int WindowID;                      /* Window handle I.D.. */
  148.     int WindowFullSize;        /* TRUE if window is using screen full size. */
  149.     IntrWindowType WindowType;
  150.     char *Name, *StatusLeft, *StatusRight; /* Strings describing the window. */
  151.     IntrBType DrawHeader;         /* TRUE will show header (if Name != NULL) */
  152.     IntrBType MappedToScreen;               /* TRUE if should be visible. */
  153.     IntrBType DrawnOnScreen;          /* TRUE if was drawn, FALSE otherwise. */
  154.     int FrameWidth;           /* Window Frame width in screen space coords. */
  155.     IntrBBoxStruct BBox;    /* Window (Interior) dimensions in screen space. */
  156.     IntrBBoxStruct PushBBox;           /* One level BBox size pushing stack. */
  157.     IntrFBBoxStruct FBBox;              /* Real coordinates of window. */
  158.     IntrScrlBarType HScrlBar, VScrlBar;         /* If should have a scroll bar. */
  159.     IntrColorType HScrlBarColor, VScrlBarColor;     /* Window Scroll Bar Color. */
  160.     IntrColorType FrameColor;                  /* Window Frame Color. */
  161.     IntrColorType BackColor;            /* Window Back Ground Color. */
  162.     int ZoomFactor, PanFactorX, PanFactorY;      /* Window drawing control. */
  163.     IntrCursorShapeStruct Cursor;      /* Cursor to use while window active. */
  164.     _IntrWndwTextStruct *TextInfo;       /* If the window is to handle text. */
  165.     struct IntrPullDownMenuStruct *PDMenu;    /* At most one pull down menu. */
  166.     IntrIntFunc RefreshFunc;             /* Window refresh function. */
  167.     struct _IntrWindowStruct *Pnext;
  168. } _IntrWindowStruct;
  169.  
  170. typedef struct IntrPopUpMenuStruct {
  171.     int NumOfEntries;                 /* Number of items in menu. */
  172.     int SizeOfEntry;                        /* Size of item. */
  173.     char *Header;                       /* Of menu - name of menu. */
  174.     char **StrEntries;                         /* The entries. */
  175.     struct IntrCursorShapeStruct Cursor; /* Cursor to use while menu active. */
  176.     IntrColorType ForeColor, BackColor, FrameColor, XorColor;/* Menu colors. */
  177.     int FrameWidth, _MenuWidth, _MenuHeight;        /* Dimensions in pixels. */
  178.     int SelectedIndex;           /* Index of last item selected when poped up. */
  179. } IntrPopUpMenuStruct;
  180.  
  181. typedef struct IntrPullDownMenuStruct {
  182.     int NumOfEntries;                 /* Number of items in menu. */
  183.     int SizeOfEntry;                        /* Size of item. */
  184.     int WindowID;    /* Pull Down menus must be associated with a window. */
  185.     char **StrEntries;                         /* The entries. */
  186.     IntrColorType ForeColor, BackColor, FrameColor, XorColor;/* Menu colors. */
  187.     int FrameWidth;                    /* Dimensions in pixels. */
  188.     IntrIntFunc *ActionFuncs;     /* Function called when menu is activated. */
  189.     int DrawnEntryWidth;           /* Width of each drawn entry in the menu. */
  190.     int _ActiveIndex;              /* -1 if none active, index if active. */
  191. } IntrPullDownMenuStruct;
  192.  
  193. /******************************************************************************
  194. * Function prototypes.                                  *
  195. ******************************************************************************/
  196.  
  197. #if defined(__cplusplus) || defined(c_plusplus)
  198. extern "C" {
  199. #endif
  200.  
  201. /* Initialization and closing routines. */
  202. void IntrInit(void);
  203. void IntrClose(void);
  204.  
  205. /* Generic routines: */
  206. void IntrFatalError(char *Msg);
  207. int IntrPopUpActive(void);
  208.  
  209. /* Color allocation routines. */
  210. int IntrAllocColor(IntrColorType Color, IntrIntensityType Intensity);
  211. void IntrAllow256Colors(IntrBType Allow256Colors);
  212.  
  213. /* Window manipulation routines. */
  214. int IntrWndwCreate(char *WindowName,
  215.            int FrameWidth,
  216.            IntrBBoxStruct *BBox,
  217.            IntrColorType FrameColor,
  218.            IntrColorType BackColor,
  219.            IntrCursorShapeStruct *Cursor,
  220.            IntrPullDownMenuStruct *PDMenu,
  221.            IntrIntFunc RefreshFunc);
  222. void IntrWndwSetRoot(int RootWindowID);
  223. void IntrWndwSelect(int WindowID);
  224. void IntrWndwSelectAll(IntrBType SelectAll);
  225. void IntrWndwRedrawAll(void);
  226. void IntrWndwClear(int WindowID);
  227. int IntrWndwPick(void);
  228. void IntrWndwPop(int WindowID, IntrBType DoRedraw, IntrBType DoClear);
  229. void IntrWndwPush(int WindowID, IntrBType DoRedraw);
  230. IntrBType IntrWndwIsAllVisible(int WindowID);
  231. void IntrWndwSetResizeBBox(IntrBBoxStruct *BBox);
  232. IntrBType IntrWndwMove(int WindowID, IntrBType Refresh);
  233. IntrBType IntrWndwResize(int WindowID, IntrBType Refresh);
  234. void IntrWndwFullSize(int WindowID, IntrBType Refresh);
  235. void IntrWndwHide(int WindowID, IntrBType Refresh);
  236. void IntrWndwDelete(int WindowID, IntrBType Refresh);
  237. int IntrWndwGetHeaderHeight(char *Header, int FrameWidth);
  238. IntrBBoxStruct *IntrWndwGetBBox(int WindowID);
  239. IntrFBBoxStruct *IntrWndwGetFBBox(int WindowID);
  240. IntrColorType IntrWndwGetFrameColor(int WindowID);
  241. IntrColorType IntrWndwGetBackGroundColor(int WindowID);
  242. IntrCursorShapeStruct *IntrWndwGetCursorShape(int WindowID);
  243. IntrPullDownMenuStruct *IntrWndwGetPullDownMenu(int WindowID);
  244. int IntrWndwGetZoomFactor(int WindowID);
  245. IntrIntFunc IntrWndwGetRefreshFunc(int WindowID);
  246. void IntrWndwGetPanFactors(int WindowID, int *x, int *y);
  247. void IntrWndwSetName(int WindowID, char *Name);
  248. void IntrWndwSetDrawHeader(int WindowID, IntrBType DrawHeader);
  249. void IntrWndwSetBBox(int WindowID, IntrBBoxStruct *BBox);
  250. void IntrWndwSetFBBox(int WindowID, IntrFBBoxStruct *FBBox);
  251. void IntrWndwSetFrameColor(int WindowID, IntrColorType FrameColor);
  252. void IntrWndwSetBackGroundColor(int WindowID, IntrColorType BackColor);
  253. IntrBType IntrWndwIsScrollBarEvent(int WindowID, IntrBType *IsVertical, IntrRType *Value);
  254. int IntrWndwScrollBarWidth(void);
  255. void IntrWndwUpdateScrollBar(int WindowID,
  256.                  IntrBType IsVertical,
  257.                      IntrRType RelativePosition,
  258.                              IntrRType DisplayedFraction);
  259. void IntrWndwSetScrlBar(int WindowID,
  260.             IntrBType IsVertical,
  261.             IntrScrlBarType ScrlBar,
  262.                         IntrColorType ScrlBarColor);
  263. void IntrWndwSetCursorShape(int WindowID, IntrCursorShapeStruct *Cursor);
  264. void IntrWndwSetPullDownMenu(int WindowID, IntrPullDownMenuStruct *PDMenu);
  265. void IntrWndwSetRefreshFunc(int WindowID, IntrIntFunc RefreshFunc);
  266. void IntrWndwUpdatePanning(int WindowID, int x, int y);
  267. void IntrWndwSetPanning(int WindowID, int x, int y);
  268. void IntrWndwUpdateZoom(int WindowID, int Zoom);
  269. void IntrWndwSetZoom(int WindowID, int Zoom);
  270. void IntrWndwSetStatus(int WindowID, char *StatusLeft, char *StatusRight,
  271.                                 IntrBType Refresh);
  272.  
  273. /* Window drawing routines. */
  274. void IntrWndwILine(int x1, int y1, int x2, int y2);
  275. void IntrWndwRLine(IntrRType x1, IntrRType y1, IntrRType x2, IntrRType y2);
  276. void IntrWndwIMoveTo(int x, int y);
  277. void IntrWndwRMoveTo(IntrRType x, IntrRType y);
  278. void IntrWndwILineTo(int x, int y);
  279. void IntrWndwRLineTo(IntrRType x, IntrRType y);
  280. void IntrWndwIMoveRel(int x, int y);
  281. void IntrWndwRMoveRel(IntrRType x, IntrRType y);
  282. void IntrWndwILineRel(int x, int y);
  283. void IntrWndwRLineRel(IntrRType x, IntrRType y);
  284. void IntrWndwIPoly(int n, int *Points, int Fill);
  285. void IntrWndwIBar(int x1, int y1, int x2, int y2);
  286. void IntrWndwRBar(IntrRType x1,
  287.           IntrRType y1,
  288.           IntrRType x2,
  289.           IntrRType y2);
  290. void IntrWndwICircle(int x, int y, int r);
  291. void IntrWndwRCircle(IntrRType x, IntrRType y, IntrRType r);
  292. void IntrWndwIArc(int x, int y, int StAngle, int EndAngle, int r);
  293. void IntrWndwRArc(IntrRType x,
  294.           IntrRType y,
  295.           int StAngle,
  296.           int EndAngle,
  297.           IntrRType r);
  298. void IntrWndwIText(int x, int y, char *s);
  299. void IntrWndwRText(IntrRType x, IntrRType y, char *s);
  300.  
  301. /* Text handling in graphic windows. */
  302. void IntrTextInitWindow(int WindowID,
  303.             IntrBType ReadBottomLine,
  304.             IntrColorType TextColor,
  305.                         IntrColorType BottomLineColor,
  306.                         IntrScrlBarType HScrlBar,
  307.                         IntrScrlBarType VScrlBar,
  308.                         int NumOfLines,
  309.                         int LineLen);
  310. void IntrTextSetSmoothScroll(IntrBType SmoothScrolling);
  311. void IntrTextWndwRefresh(int WindowID);
  312. void IntrPrintf(int WindowID, IntrBType UpdateWindow, char *CtrlStr, ...);
  313. void IntrGetLineWindow(int WindowID, char *Buffer, int BufferLen);
  314.  
  315. /* Cursor control routines. */
  316. void IntrUseMouseDriverCursor(IntrBType UseMouseCursor);
  317. void IntrPushCursorType(void);
  318. void IntrPopCursorType(void);
  319. IntrCursorShapeStruct *IntrGetCursorType(void);
  320. void IntrSetCursorType(IntrCursorShapeStruct *Cursor);
  321. void IntrSetCursorType2(IntrCursorType CursorType,
  322.                 void (* CursorRoutine)(int, int),
  323.                 int Width, int Height, int LastX, int LastY,
  324.                 IntrBType LastHV);
  325. void IntrShowCursor(int x, int y);
  326. void IntrReposCursor(int x, int y);
  327. void IntrUnShowCursor(void);
  328.  
  329. /* Simple messages mechanism. */
  330. void IntrDrawMessage(char *Str, IntrColorType ForeColor,
  331.                             IntrColorType BackColor);
  332. void IntrEraseMessage(void);
  333.  
  334. /* Input event handling routines. */
  335. int IntrGetch(void);
  336. int IntrKbHit(void);
  337. void IntrSetIdleFunction(IntrVoidFunc IdleFunction);
  338. void IntrSetAtKeyboard(IntrBType IsATKeyboard);
  339. void IntrSetMouseSensitivity(int Sensitivity);
  340. IntrBType IntrRegisterKeyStroke(int KeyStroke, IntrIntFunc ActionFunc);
  341. void IntrSetInputDevice(int Devices);
  342. void IntrSetHandleInternalEvents(IntrBType HandleEvents,
  343.                  IntrBType PropagateEvents);
  344. void IntrInputFlush(void);
  345. IntrEventType IntrGetEventWaitSA(int *x, int *y);
  346. IntrEventType IntrGetEventWait(int *x, int *y);
  347. IntrEventType IntrGetEventNoWait(int *x, int *y);
  348. IntrEventType IntrGetTextEventWait(void);
  349. IntrEventType IntrGetTextEventNoWait(void);
  350. void IntrPushKbdEvent(int KbdEvent);
  351. IntrBType IntrMapEventToWindow(int WindowID, int x, int y, int *Wx, int *Wy);
  352. IntrBType IntrMapEventToRWindow(int WindowID, int x, int y,
  353.                           IntrRType *Wx, IntrRType *Wy);
  354.  
  355. /* Routines to control images back saving. */
  356. void IntrSetAsyncEventMode(IntrBType AsyncMode);
  357. void IntrSetSaveBackGround(IntrBType SaveBackGround);
  358. void IntrSetSaveBackMethod(IntrSaveMemType SaveBackMethod);
  359. void IntrSetSaveBackPath(char *Path);
  360.  
  361. /* Query Interaction routines. */
  362. void IntrQueryContinue(char *Question,
  363.                IntrColorType FrameColor,
  364.                IntrColorType BackColor,
  365.                IntrColorType ForeColor,
  366.                IntrColorType XorColor,
  367.                        int FrameWidth,
  368.                        IntrCursorShapeStruct *Cursor,
  369.                        int WindowID);
  370. void IntrQueryContinue2(char *Question,
  371.             void (* ExecFunc)(void),
  372.                 IntrColorType FrameColor,
  373.                 IntrColorType BackColor,
  374.                 IntrColorType ForeColor,
  375.                         int FrameWidth,
  376.                         IntrCursorShapeStruct *Cursor,
  377.                         int WindowID);
  378. IntrBType IntrQueryYesNo(char *Question,
  379.                  IntrColorType FrameColor,
  380.                  IntrColorType BackColor,
  381.                  IntrColorType ForeColor,
  382.                  IntrColorType XorColor,
  383.                          int FrameWidth,
  384.                          IntrCursorShapeStruct *Cursor,
  385.                          int WindowID);
  386. char *IntrQueryLine(char *Question,
  387.             char *Buffer,
  388.                     int BufferSize,
  389.             IntrColorType FrameColor,
  390.             IntrColorType BackColor,
  391.             IntrColorType ForeColor,
  392.                     int FrameWidth,
  393.                     int WindowID);
  394. int IntrQueryList(char *Header,
  395.           char **StrEntries,
  396.           int SizeOfEntry,
  397.                   int NumOfEntries,
  398.                   int NumOfDisplayedEntries,
  399.           IntrColorType FrameColor,
  400.           IntrColorType BackColor,
  401.           IntrColorType ForeColor,
  402.           IntrColorType XorColor,
  403.           int FrameWidth,
  404.                   IntrCursorShapeStruct *Cursor,
  405.                   int WindowID);
  406.  
  407. /* Pop Up Menu Interaction routines. */
  408. void IntrPullDownMenuDelete(IntrPullDownMenuStruct *Menu);
  409. IntrPopUpMenuStruct *IntrPopUpMenuCreate(char *Header,
  410.                      char **StrEntries,
  411.                      int SizeOfEntry,
  412.                                          int NumOfEntries,
  413.                      IntrColorType FrameColor,
  414.                          IntrColorType BackColor,
  415.                          IntrColorType ForeColor,
  416.                          IntrColorType XorColor,
  417.                              int FrameWidth,
  418.                                          IntrCursorShapeStruct *Cursor);
  419. void IntrPopUpMenuDelete(IntrPopUpMenuStruct *Menu);
  420. void IntrPopUpSetEntry(IntrPopUpMenuStruct *PUMenu, char *Entry, int Index);
  421. void IntrPopUpSetHeader(IntrPopUpMenuStruct *PUMenu, char *Header);
  422. void IntrPopUpSetFrameWidth(IntrPopUpMenuStruct *PUMenu, int FrameWidth);
  423. void IntrPopUpSetColors(IntrPopUpMenuStruct *PUMenu,
  424.                 IntrColorType FrameColor,
  425.                 IntrColorType BackColor,
  426.                 IntrColorType ForeColor,
  427.                 IntrColorType XorColor);
  428. int IntrPopUpMenu(IntrPopUpMenuStruct *PUMenu,
  429.                   int WindowID);
  430.  
  431. /* Pull Down Menu Interaction routines. */
  432. IntrPullDownMenuStruct *IntrPullDownMenuCreate(char **StrEntries,
  433.                            int SizeOfEntry,
  434.                                                int NumOfEntries,
  435.                            IntrIntFunc *ActionFuncs,
  436.                                IntrColorType FrameColor,
  437.                                IntrColorType BackColor,
  438.                                IntrColorType ForeColor,
  439.                                IntrColorType XorColor,
  440.                                    int FrameWidth);
  441. void IntrPullDownSetEntry(IntrPullDownMenuStruct *PDMenu, char *Entry,
  442.                                 int Index);
  443. void IntrPullDownSetAction(IntrPullDownMenuStruct *PDMenu,
  444.                 IntrIntFunc ActionFunc, int Index);
  445. void IntrPullDownSetFrameWidth(IntrPullDownMenuStruct *PDMenu, int FrameWidth);
  446. void IntrPullDownSetColors(IntrPullDownMenuStruct *PDMenu,
  447.                    IntrColorType FrameColor,
  448.                    IntrColorType BackColor,
  449.                    IntrColorType ForeColor,
  450.                    IntrColorType XorColor);
  451.  
  452. #if defined(__cplusplus) || defined(c_plusplus)
  453. }
  454. #endif
  455.  
  456. #endif /* INTR_LIB_H */
  457.